package com.guli.mall.member.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guli.common.constant.MemberConstant;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guli.common.utils.PageUtils;
import com.guli.common.utils.Query;

import com.guli.mall.member.mapper.MemberLevelMapper;
import com.guli.mall.member.entity.MemberLevelEntity;
import com.guli.mall.member.service.MemberLevelService;


@Service("memberLevelService")
public class MemberLevelServiceImpl extends ServiceImpl<MemberLevelMapper, MemberLevelEntity> implements MemberLevelService {

    @Override
    public PageUtils<MemberLevelEntity> queryPage(Integer currentPage, Integer size, Map<String, Object> params) {

        Page<MemberLevelEntity> page = new Page<>(currentPage, size);

        Page<MemberLevelEntity> resultPage = this.page(page);


        return new PageUtils<>(resultPage);
    }

    @Override
    public MemberLevelEntity getDefaultMemberLevel() {

        QueryWrapper<MemberLevelEntity> wrapper = new QueryWrapper<>();

        wrapper.eq("default_status", MemberConstant.DefaultMemberLevel.YES.getCode());

        return this.getOne(wrapper,false);
    }

}